package com.cskaoyan.exception_handler;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.boot.json.JsonParseException;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;

/**
 * xdx
 * 2020/12/11
 * 10:06
 *
 */
@ControllerAdvice
public class JsonParseExceptionHandler {
    @ExceptionHandler(value = HttpMessageNotReadableException.class)
    @ResponseBody
    public BaseRespVo ret(){
        return BaseRespVo.fail("参数格式不合法，请重新输入-by Exception Handler");
    }
}
